{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}{{'邮箱设置'|trans}} - {{ parent() }}{% endblock %}

{% set script_controller = 'settings/email' %}

{% set side_nav = 'email' %}

{% block main %}
  {% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
    {% block heading %}{{'邮箱设置'|trans}}{% endblock %}
    {% block body %}
    {% if mailer.enabled == 1 or cloudEmail.status|default(null) == 'enable' %}
      <form id="setting-email-form" class="form-horizontal" method="post" >
        {{ web_macro.flash_messages() }}

        <div class="form-group">
          <div class="col-md-2 control-label"><label>{{'当前登录邮箱'|trans}}</label></div>
          <div class="col-md-8 controls">
            <span class="control-text">
              {% set emailArr = app.user.email|split('@') %}
              {% if emailArr[1] != 'edusoho.net' %}
                {{ app.user.email }}
                {% if app.user.emailVerified %}
                  <span class="text-success">({{'已验证'|trans}})</span>
                {% else %}
                  <p class="help-block mtm">
                    {{'邮箱地址尚未验证，'|trans}}
                    <a id="send-verify-email" class="btn btn-info btn-sm" href="javascript:;" data-url="{{ path('settings_email_verify') }}">{{'去验证'|trans}}</a>
                  </p>
                {% endif %}
              {% else %}
                <span class="text-success">{{'您还未设置邮箱，请在下方设置你的新邮箱。'|trans}}</span>
              {% endif %}

            </span>
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label" for="{{ '新登录邮箱'|trans }}">{{ form_label(form.email, '新登录邮箱'|trans) }}</div>
          <div class="col-md-8 controls">
            {{ form_widget(form.email, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.password, '网站登录密码'|trans) }}</div>
          <div class="col-md-8 controls">
            {{ form_widget(form.password, {attr:{class:'form-control'}}) }}
            <p class="help-block">{{'设置新的登录邮箱，需要校验当前的网站登录密码'|trans}}</p>
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label"></div>
          <div class="col-md-8 controls">
            {{ form_rest(form) }}
            <button id="email-save-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary">{{'提交'|trans}}</button>
          </div>
        </div>

        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
      </form>
    {% else %}
      <div class="alert alert-danger">{{'管理员尚未设置邮件服务器，不能更改邮箱地址。'|trans}}</div>
    {% endif %}
    {% endblock %}
  {% endembed %}
{% endblock %}